#include "stdafx.h"
#include "ImageButton.h"

#ifdef _DEBUG
#define new DEBUG_NEW
#undef THIS_FILE
static char THIS_FILE[] = __FILE__;
#endif

CImageButton::CImageButton()
{
}

CImageButton::~CImageButton()
{
}


BEGIN_MESSAGE_MAP(CImageButton, CStatic)
	//{{AFX_MSG_MAP(CImageButton)
		// NOTE - the ClassWizard will add and remove mapping macros here.
	//}}AFX_MSG_MAP
END_MESSAGE_MAP()

void CImageButton::SetPressed(BOOL IsNeedPressed)
{
	if(IsNeedPressed)
	{
		if(!this->m_IsPressed)
		{
			HBITMAP hBitmap =  (HBITMAP)::LoadImage(AfxGetInstanceHandle(), MAKEINTRESOURCE(this->m_hBitmapPressed), IMAGE_BITMAP,0,0, LR_CREATEDIBSECTION);
			this->SetBitmap(hBitmap);
			this->m_IsPressed = TRUE;
		}
	}
	else
	{
		if(this->m_IsPressed)
		{
			HBITMAP hBitmap =  (HBITMAP)::LoadImage(AfxGetInstanceHandle(), MAKEINTRESOURCE(this->m_hBitmapNormal), IMAGE_BITMAP,0,0, LR_CREATEDIBSECTION);
			this->SetBitmap(hBitmap);
			this->m_IsPressed = FALSE;
		}
	}
}

void CImageButton::Initial(BOOL IsPressed, int intBitmapNormal, int intBitmapPressed)
{
	this->m_IsPressed = IsPressed;
	this->m_hBitmapNormal = intBitmapNormal;
	this->m_hBitmapPressed = intBitmapPressed;
}

BOOL CImageButton::GetPressedStatus()
{
	return this->m_IsPressed;
}
